#include "rclcpp/rclcpp.hpp"
#include "geometry_msgs/msg/twist.hpp"
#include <chrono>
#include "turtlesim/msg/pose.h"

using namespace std::chrono_literals;

class TurtirCircleNode :public rclcpp::Node
{
    private:
        //计时器共享指针 
        rclcpp::TimerBase::SharedPtr timer_;
        // 发布者智能指针
        rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr publisher_;

    public:
        // explicit防止隐式转换
        explicit TurtirCircleNode(const std::string& node_name ):Node(node_name)
        {
            // 创建发布者
            publisher_=this->create_publisher<geometry_msgs::msg::Twist>("/turtle1/cmd_vel",10);
            timer_=this->create_wall_timer(1000ms,std::bind(&TurtirCircleNode::time_callback,this));
        }
    
        void time_callback()
        {
            auto msg =geometry_msgs::msg::Twist();
            msg.linear.x=1.0;
            msg.angular.z=0.5;
            publisher_->publish(msg);
        }
};

int main(int argc, char** argv)
{
    rclcpp::init(argc,argv);
    auto node =std::make_shared<TurtirCircleNode> ("TurtirCircleNode");
    rclcpp::spin(node);

    rclcpp::shutdown();
    return 0;
}